﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Gype.GUI.Components
{
    public class MouseMessage : ControlMessage
    {
        public MouseMessage(InputMessage msg)
            : base(msg)
        {
            X = mOrigMessage.lParam.X();
            Y = mOrigMessage.lParam.Y();
        }

        public MouseMessage()
            : base(null)
        {

        }

        public int X { get; private set; }
        public int Y { get; private set; }
        public Win32Native.ModifierKeys Modifiers { get { return (Win32Native.ModifierKeys)mOrigMessage.wParam.wParam.ToInt32(); } }

        public override void ForwardMessage(Component source, Component dest)
        {
            MouseMessage forward = new MouseMessage();
            forward.mOrigMessage = mOrigMessage;

            forward.X = X - (int)dest.Location.X;
            forward.Y = Y - (int)dest.Location.Y;

            if (source != null)
            {
                forward.X -= (int)source.getChildOffset().X;
                forward.Y -= (int)source.getChildOffset().Y;
            }

            dest.OnMessage(forward);
        }
    }
}
